<?php
include "connect.php";
$name=$_GET['user'];
$cpassword=$_POST['cpassword'];
$npassword=$_POST['npassword'];
$vpassword=$_POST['vpassword'];
if($cpassword=='')
{
header("Location:change password student.php");
}
else if($npassword=='')
{
header("Location:change password student.php");
}
else if($vpassword=='')
{
header("Location:change password student.php");
}
else if($npassword!=$vpassword)
{
header("Location:change password student.php");
}
else
{
$sq="select * From student_login where reg_no='$name'";
$result=mysql_query($sq) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$ck=$row['password'];
if ($cpassword!=$ck)
{
header("Location:change password student.php");
}
else
{
$sql="UPDATE student_login SET password='$npassword' where reg_no='$name'";
$uresult=mysql_query($sql) or die(mysql_error());
if($sql)
{
header("Location:change password student.php");

}
else
{

die('some sort of error'.mysql_error());

}}}}
?>